package randombeanmachine;

import java.util.Date;

public class Random {
    private int sign;
    private int lowerBound;
    private int upperBound;

    public Random() {
        this(1);
    }

    public Random(int sign) {
        this(sign, 0, Integer.MAX_VALUE);
    }

    public Random(int sign, int lowerBound, int upperBound) {
        this.sign = sign;
        this.lowerBound = lowerBound;
        this.upperBound = upperBound;
    }

    public int nextInt() {
        return random().nextInt(betweenBounds()) + lowerBound;
    }

    private int betweenBounds() {
        return upperBound - lowerBound;
    }

    private java.util.Random random() {
        return new java.util.Random();
    }

    public boolean nextBoolean() {
        return random().nextBoolean();
    }

    public Character[] nextCharacters(int numberOfCharacters) {
        Character[] characters = new Character[numberOfCharacters];
        for (int i = 0; i < characters.length; i++) {
            characters[i] = nextCharacter();
        }
        return characters;
    }

    public double nextDouble() {
        return random().nextInt() + random().nextDouble();
    }

    public Character nextCharacter() {
        int i = between(58, 122).nextInt();
        return (char) i;
    }

    public Date nextNormalisedDate() {
        return new Date();
    }

    public Date nextRandomDate() {
        return new Date();
    }

    public String[] nextStrings(int numberOfStrings) {
        String[] strings = new String[numberOfStrings];
        for (int i = 0; i < strings.length; i++) {
            strings[i] = nextString(25);
        }
        return strings;
    }

    public String nextString(int sizeOfString) {
        Character[] characters = nextCharacters(sizeOfString);
        StringBuffer buffer = new StringBuffer();
        for (Character character : characters) {
            buffer.append(character);
        }
        return buffer.toString();
    }

    public static long nextLong() {
        return new Random(1).nextInt();
    }

    public static Random between(int lowerBound, int upperBound) {
        return new Random(1, lowerBound, upperBound);
    }

    public static Character[] characters(int numberOfCharacters) {
        return new Random().nextCharacters(numberOfCharacters);
    }
}
